<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>watch练习</title>
    <script src="../../js/vue.js"></script>
  </head>
  <body>
    <div id="app">
      <input type="text" v-model="str" />
    </div>
    <script>
      var v_app = new Vue({
        el: "#app",
        data: {
          str: "hello",
        },
        watch: {
          str: function (newStr, oldStr) {
            console.log("新词语:" + newStr + " 旧词语:" + oldStr);
          },
        },
      });
    </script>
  </body>
</html>
